<!DOCTYPE html>
  <html>
  <head>
      <meta charset="utf-8">
      <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
      <title>title</title>
      <link rel="stylesheet" type="text/css" href="../css/api.css"/>
      <style>
      body{
          padding-top: 1.5rem;
      }
      .header{
            width: 94%;
            height: 5.5rem;
            line-height: 2.5rem;
            padding: 0.5rem 0.8rem;
            text-align: center;
            position: fixed;
            top:1.5rem;
            background-color: #fff;
            z-index: 999;
        }
        .header_img{
          width: 6%;
          height: 20%;
          float: left;
          margin-top: 0.5rem;
        }
      .header_img img{
        width: 100%;
        height: 100%;
      }
      .header h3{
        line-height: 3rem;
        width:30%;
        margin-left: 5.5rem;
        text-align: center;
        float: left;
      }
      .ul{
        width: 93%;
        height: 2rem;
        padding: 0.5rem 0.8rem;
      }
      #a {
          color: #40cccc;
          border-bottom: 0.1rem solid #40cccc;
      }
      .ul ul{
        width: 50%;
        height: 2rem;
        line-height: 2rem;
        display: flex;
        justify-content: space-between;
        margin-left: 2rem;
      }
      .ul ul li{
        width: 26%;
        height: 2rem;
        float: left;
      }
      .ul ul li a{
        text-align: center;
        color: black;
        font-size: 1.2rem;
      }
      .content{
        width: 93%;
        padding: 0.5rem 0.8rem;
        margin-top: 1rem;
      }
      .now{
        width: 90%;
        height: 100%;
        margin: 1rem auto;
        border-left: 0.1rem solid #c2d5d1;
      }
      .cont_one{
        width: 100%;
        height: 10rem;
        margin: 1rem auto;
        position: relative;
        padding-top:3rem;

      }
      .cont_top{
        width: 100%;
        height: 3.5rem;
      }
      .one_left{
        position: absolute;
        left:-8%;
        width: 18%;
        height:3.5rem;
        background-color: #fff;
        text-align: center;
        padding-top:0.5rem;
      }
      .p{
        height: 3rem;
        margin-left:2.5rem;
        line-height: 3rem;
        padding-top:0.5rem;
      }
      .fl{
        float: left;
      }
      .cont_img{
        width: 87%;
        float: right;
        height: 35%;
        margin-top: 1.5rem;
        border-radius: 1rem;
      }
      .cont_img img{
        width: 100%;
        height: 100%;
      }
      .left{
        position: absolute;
        left:-5%;
        width: 10%;
        height:10%;
        background-color: #fff;
        text-align: center;
        margin-top: 1.5rem;
      }
      .left img{
        width: 100%;
        height: 100%
      }
      .two{
        height: 15rem;

      }
      .one_right{
        width: 80%;
        float: right;
        background-color:  rgb(242, 242, 242, 0.2);
        height: auto;
        margin-top: 1.5rem;
        padding: 0.5rem 0.2rem 0.5rem 0.8rem;
            }
    .da{
      width: 15%;
      /*height: 1.5rem;*/
      line-height: 1.5rem;
      font-size: 0.9rem;
      color: #fff;
      background-color: #71af21;
      text-align: center;
      border-radius: 2rem;
      margin-bottom: 0.5rem;
    }
    .p_bottom{
      height: 1.2rem;
      line-height: 1.2rem;
      font-size: 0.8rem;
      margin-top: 3rem;
      color: #ccc;
    }
    .bottom_p{
      margin-right: 0.8rem;
      background-color: #ccc;
      color: #fff;
    }
    .h2{
      /*width: 100%;*/
      height: 1.5rem;
      position: relative;
      left:-8%;
      text-align: left;
      margin-top: 1.5rem;
      margin-left: 0.5rem;
      margin-bottom: 0.5rem;
    }
    .right_img{
      width: 100%;
      height: 2rem;
      margin-top: 2rem;
    }
    .img{
      width: 10%;
      height: 67%;
      margin-left: 1rem;
      margin-top: 0.15rem;
    }

    .img img{
      width: 100%;
      height: 100%;
    }
    .imgs{
      width: 10%;
      height: 67%;
      /*margin-left: 1rem;*/
    }
    .imgs img{
      width: 100%;
      height: 100%;
    }
    .fr{
      float: right;
    }
  .h2{
    position: absolute;
    left:0%;
    text-align: center;
    margin-top: 1.5rem;
    background-color: #fff;
  }
  .dw{

    position: fixed;
    bottom: 2rem;
    left:17rem;
    z-index: 999;
  }
      </style>
  </head>
  <body>
    <div class="header">
      <div class="header_img">
        <img src="../image/u18.png" alt="" onclick="closewin()">
      </div>
      <h3 style="">成长日记</h3>
      <h3 onclick="set_qx()" id="qx_s" style="margin-left:0.5rem;text-align:right;padding-right:0.5rem">已公开</h3>
      <div class="ul">
        <ul>
          <li id="a"><a href="#">成长</a></li>
          <!-- <li><a href="#">相册</a></li> -->
        </ul>
      </div>
    </div>
<div class="content">
<div class="now" id="rjlist">

  <!-- <h2 class="h2">2018年</h2>
  <div class="cont_one two" style="margin-top:5rem">

    <div class="cont_top">
      <div class="one_left fl">
        <h2>26</h2>
        <p>12月</p>
      </div>
      <p class="fl p">10个月6天</p>
    </div>
    <div class="left">
      <img src="../image/u24.png" alt="">
    </div>
    <div class="one_right">
        <p class="da">精笔</p>
        <p>坚持</p>
        <div class="p_bottom">
          <p class="bottom_p fl">小步在家早教用户可见</p>
          <p class="fl">来自妈妈</p>
        </div>
        <div class="right_img">
          <div class="imgs fl">
            <img src="../image/wo.png" alt="">
          </div>
          <div class="img fr">
            <img src="../image/wo.png" alt="">
          </div>
          <div class="img fr">
            <img src="../image/wo.png" alt="">
          </div>
          <div class="img fr">
            <img src="../image/wo.png" alt="">
          </div>
        </div>
    </div>
  </div> -->
</div>
</div>
<div onclick="add_rj()" class="dw"><img src="../image/add.png" width="90%" height="90%"></div>
  </body>
  <script type="text/javascript" src="../script/api.js"></script>
      <script type="text/javascript" src="../script/jquery-1.8.3.js"></script>
  <script type="text/javascript" src="../script/common.js"></script>
  <script type="text/javascript">
  var userinfo = $api.getStorage('userinfo');
  var page = 1;
  var pagesize = 10;
  var years
  var ok = true
  var qx
      apiready = function(){
        api.sendEvent({
            name: 'rjlb',

        });
        get_list()
        api.addEventListener({
             　　name:'scrolltobottom',
                 extra:{threshold:0}
             }, function(ret, err){
      　　　　　　get_list()
            });
            api.addEventListener({
                name:'add_posting',
                extra:{
                    threshold:0
                }
            }, function(ret, err){
              page = 1;
              ok = true
              years = 0
              $("#rjlist").html('')
              get_list()
                  //alert( JSON.stringify( ret ) );
            });
      };

      function set_qx() {
        api.ajax({
            url: SITE_URL+'user_api/baby/set_qx',
            method: 'post',
            data: {
                values: {
                    user_id: userinfo.id,
                    type:qx
                }
            }
        },function(ret, err){
            if (ret) {
              if(ret.error==200){
                if(qx==1){//取消权限
                  msgcode('已设为公开')
                  $("#qx_s").html('已公开')
                    $(".qxs").html('所有人可见')
                    qx=0
                }else{
                  qx=1
                    $(".qxs").html('仅自己可见')
                  $("#qx_s").html('私密')
                  msgcode('已设为私密')
                }
              }else{
                msgcode('设置失败')
              }
              //  alreert( JSON.stringify( ret ) );
            } else {
              msgcode('请检查网络连接')
//                alert( JSON.stringify( err ) );
            }
        });

      }

      function add_rj() {
        api.openWin({
            name: 'add_rj',
            url: './add_rj.html'
        });
      }

      function get_list() {
        if(ok==false){
          return false
        }
        var html = ''
        var obj = $api.byId('rjlist');

        api.ajax({
            url: SITE_URL+'user_api/baby/get_rj',
            method: 'post',
            data: {
                values: {
                    user_id: userinfo.id,
                    page:page,
                    pagesize:pagesize
                }
            }
        },function(ret, err){
            if (ret) {
              if(ret.error==200){
                for (var i = 0; i < ret.data.length; i++) {
                  var dat = ret.data[i]
                  if(dat.year!=years){
                    html +='<h2 class="h2">'+dat.year+'年</h2>'
                    years = dat.year
                  }
                  if(i==0){
                    if(dat.state==1){
                      $("#qx_s").html('私密')

                      qx = 1
                    }else{
                      qx = 0

                      $("#qx_s").html('公开')
                    }
                  }
                  html +='<div class="cont_one two" style="margin-top:5rem">'
                    html +='<div class="cont_top">'
                      html +='<div class="one_left fl">'
                        html +='<h2>'+dat.day+'</h2>'
                        html +='<p>'+dat.month+'月</p>'
                      html +='</div>'
                      html +='<p class="fl p">'+dat.stime+'</p>'
                    html +='</div>'
                    html +='<div class="left">'
                      html +='<img src="../image/u24.png" alt="">'
                    html +='</div>'
                    html +='<div class="one_right"  onclick="opens('+dat.id+')">'

                        html +='<p>'+cutstr(dat.content,50)+'</p>'
                        if(dat.img_list.length>0 && dat.img_list!=''){
                          for (var ies = 0; ies < dat.img_list.length; ies++) {
                            var date = dat.img_list[ies]
                            html+='<img src="'+date+'" style="width:4rem;height:4rem;float:left;margin:0.3rem 0.2rem 0.5rem 0rem;">'
                          }
                        }

                        html +='<div class="p_bottom">'
                        if(dat.state==1){
                            html +='<p class="bottom_p fl qxs"  style="clear:both">仅自己可见</p>'
                        }else{
                          html +='<p class="bottom_p fl qxs"  style="clear:both">所有人可见</p>'
                        }

                          html +='<p class="fl">来自'+userinfo.nick_name+'</p>'
                        html +='</div>'
                        html +='<div class="right_img">'
                          html +='<div class="imgs fl">'
                            html +='<img src="../image/slh.png" alt="">'
                          html +='</div>'
                          // html +='<div class="img fr">'
                          //   html +='<img src="../image/zf.png" alt="">'
                          // html +='</div>'
                          html +='<div class="img fr">'
                            html +='<img src="../image/xx.png" alt="">'
                          html +='</div>'
                          // html +='<div class="img fr" style="width:10%;height:78%;margin-top:0rem;">'
                          //   html +='<img src="../image/zan.png" alt="">'
                          html +='</div>'
                        html +='</div>'
                        html +='</div>'
                        html +='</div>'



                }
                $api.append(obj, html);
                page +=1

              }else{
                msgcode('暂无更多记录')
                ok = false
              }
//                alert( JSON.stringify( ret ) );
            } else {
              msgcode('请检查网络连接')
  //              alert( JSON.stringify( err ) );
            }
        });

      }
      function opens(id) {
        // alert(id)
          api.openWin({
              name: 'posting',
              url: './posting.html',
              pageParam: {
                          id: id
                      }
          });
      }
  </script>
  </html>
